package com.components.base.utils

import android.graphics.Rect
import android.view.View

object EventUtils {

    /**判断点击事件是否在View内*/
    fun isInViewZone(view: View, x: Double, y: Double): Boolean {
        val mChangeImageBackgroundRect = Rect()
        view.getDrawingRect(mChangeImageBackgroundRect)
        val location = IntArray(2)
        view.getLocationOnScreen(location)
        mChangeImageBackgroundRect.left = location[0]
        mChangeImageBackgroundRect.top = location[1]
        mChangeImageBackgroundRect.right = mChangeImageBackgroundRect.right + location[0]
        mChangeImageBackgroundRect.bottom = mChangeImageBackgroundRect.bottom + location[1]
        return mChangeImageBackgroundRect.contains(x.toInt(), y.toInt())
    }

}